/*
 * @Author: szx
 * @Date: 2022-04-09 15:14:05
 * @LastEditTime: 2022-04-09 15:35:52
 * @Description:
 * @FilePath: \leetcode\700-799\780\780.js
 */

/**
 * @param {number} sx
 * @param {number} sy
 * @param {number} tx
 * @param {number} ty
 * @return {boolean}
 */


var reachingPoints = function (sx, sy, tx, ty) {
    while (tx > sx && ty > sy && tx != ty) {
        if (tx > ty) {
            tx %= ty;
        } else {
            ty %= tx;
        }
    }
    if (tx === sx && ty === sy) {
        return true;
    } else if (tx === sx) {
        return ty > sy && (ty - sy) % tx === 0;
    } else if (ty === sy) {
        return tx > sx && (tx - sx) % ty === 0;
    } else {
        return false;
    }
};

console.log(reachingPoints(1, 1, 3, 5));
console.log(reachingPoints(1, 1, 2, 2));
console.log(reachingPoints(1, 1, 1, 1));
console.log(reachingPoints(6, 5, 11, 16));
